// uuid.js
export function generateUUID() {
    const arr = new Uint8Array(16);
    crypto.getRandomValues(arr);
    arr[6] = (arr[6] & 0x0f) | 0x40;
    arr[8] = (arr[8] & 0x3f) | 0x80;
    return (
        Array.from(arr.slice(0, 4), byte => byte.toString(16).padStart(2, '0')).join('') +
        '-' +
        Array.from(arr.slice(4, 6), byte => byte.toString(16).padStart(2, '0')).join('') +
        '-' +
        Array.from(arr.slice(6, 8), byte => byte.toString(16).padStart(2, '0')).join('') +
        '-' +
        Array.from(arr.slice(8, 10), byte => byte.toString(16).padStart(2, '0')).join('') +
        '-' +
        Array.from(arr.slice(10), byte => byte.toString(16).padStart(2, '0')).join('')
    );
}

const UUIDPlugin = {
    install(app) {
        app.config.globalProperties.$generateUUID = generateUUID;
    }
};

export default UUIDPlugin;

